validate

inline fun <ERR, A> A.validate(predicate: (A) -> Boolean, error: (A) -> ERR): ValidatedNel<ERR, A>(source)

Given a predicate and an error generating function return either the original value in a ValidNel if the predicate evaluates as true or the generated error in an InvalidNel.

eg: "hi mum".validate({it.contains("hi")},{"where's your manners?"})